package com.hyuk.hyukfgw.listener;

import com.hyuk.hyukfgw.framework.dispatch.SpringCtxUtils;
import com.hyuk.hyukfgw.util.excp.FgwCodeEnum;
import com.hyuk.hyukfgw.util.excp.FgwException;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class SpringBeanOpsChangeExecutor extends AbstractOpsChangeExecutor implements OpsChangeExecutor {
    
    @Override
    public int getType() {
        return 2;
    }
    
    @Override
    protected Object getInstance(String className) {
        try {
            return SpringCtxUtils.getBean(Class.forName(className));
        } catch (ClassNotFoundException exception) {
            log.warn("[SpringBeanOpsChangeExecutor] 未获取到 bean instance, className ; {}", className);
            throw new FgwException(FgwCodeEnum.ARGS_ERROR);
        }
    }
}
